<?php
// +----------------------------------------------------------------------
// | Author: derek <693472824@qq.com> <http://www.bloveambition.com/>
// +----------------------------------------------------------------------

namespace Blovex4\Controller;

/**
 * 后台首页控制器
 * @author derek <693472824@qq.com>
 */
class IndexController extends BaseController {
	
    /**
     * 后台首页
     * @author derek <693472824@qq.com>
     */
    public  function  index()
    {
        $this->meta_title = '管理首页';
        $this->display();
    
    }
    
    /**
     * 修改密码
     * @param int $adminid 用户ID
     * @param string $pwd 用户新密码
     * @author derek <693472824@qq.com>
     */
    public function updatePassword(){
    
        if (IS_POST) {
            
            $adminid = I('admin_id');
            $password = I('password');
            $repassword = I('repassword');
            
            if (empty($adminid) || empty($password) || empty($repassword)) {
                $this->error('参数错误');
            }
            
            $admin = D('Admin', 'Logic');
            $result = $admin->updatePassword($adminid, $password, $repassword);
    
            if ($result === false) {
                $this->error('操作失败'.$admin->getError());
            } else {
                $this->success('操作成功！');
            }
        }else{
    
            $this->display('Admin/updatePassword');
        }
    }
     
}